package CreateThread;

import lombok.extern.slf4j.Slf4j;

@Slf4j(topic = "TestSleepAndYield")
public class TestSleepAndYield {
    private Thread thread = new Thread() {
        @Override
        public void run() {
        }
    };

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                try {
                    log.debug("enter sleep....");
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    log.debug("wake up...");
                    throw new RuntimeException(e);
                }
            }
        };
        t1.setName("t1");
        t1.start();
        System.out.println(t1.getState());
        Thread.sleep(500);
        System.out.println(t1.getState());
        t1.interrupt();
        log.debug("interrupted");
        System.out.println(t1.getState());

    }
}
